<template>
  <div class="container">
    <div class="screen" ref="screen">
      <!-- 数据大屏顶部 -->
      <div class="top">
        <Top />
      </div>
      <div class="bottom">
        <div class="left">
          <Tourist class="tourist aaa" />
          <Sex class="sex aaa" />
          <Age class="age aaa" />
        </div>
        <div class="middle">
          <Maps class="map" />
          <Line class="line" />
        </div>
        <div class="right">
          <Rank class="rank aaa" />
          <!-- <Year class="year aaa" />
          <Counter class="counter aaa" /> -->
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue';
// 引入组件
import Top from './components/top/index.vue';
import Tourist from './components/tourist/index.vue';
import Sex from './components/sex/index.vue';
import Age from './components/age/index.vue';
import Maps from './components/map/index.vue';
import Line from './components/line/index.vue';
import Rank from './components/rank/index.vue';
const screen = ref();
onMounted(() => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`;
})
// 定义大屏缩放比例
const getScale = (w = 1920, h = 1080) => {
  const ww = window.innerWidth / w;
  const wh = window.innerHeight / h;
  return ww < wh ? ww : wh;
}
// 监听页面重构事件
window.addEventListener('resize', () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`;
});
</script>

<style scoped lang="scss">
.container {
  .aaa {
    margin-top: 10px;
  }

  height: 100vh;
  width: 100vw;
  background: url(./images/bg.png) no-repeat;
  background-size: cover;

  .screen {
    position: fixed;
    left: 50%;
    top: 50%;
    height: 1080px;
    width: 1920px;
    transform-origin: left top;

    .top {
      width: 100%;
      height: 40px;
    }

    .bottom {
      display: flex;

      .left {
        flex: 1;
        height: 1040px;
        display: flex;
        flex-direction: column;



        .tourist {
          flex: 1.5;
        }

        .sex {
          flex: 1;
        }

        .age {
          flex: 1;
        }
      }

      .right {
        flex: 1;
        height: 1040px;
        display: flex;
        flex-direction: column;

        .rank {
          flex: 1.5;
        }

        .year {
          flex: 1
        }

        .counter {
          flex: 1
        }
      }

      .middle {
        flex: 2;
        margin: 0 10px;
        margin-top: 40px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;

        .map {
          flex: 4;
        }

        .line {
          flex: 1
        }
      }
    }
  }
}
</style>
